perm filename TJMAN.DCS[UP,DOC] blob sn#002764 filedate 1972-06-11 generic text, type T, neo UTF8
TJ -- a Text Justifier		 				1

                          TABLE OF CONTENTS
                                    
                                    
                                    
                                    
CONTENT                                                    PARAGRAPH
   
   
   
SECTION 1--INTRODUCTION
   
SECTION 2--NORMAL OPERATION
   
SECTION 3--CONTROL CHARACTERS
   
SECTION 4--COMMANDS
   
SECTION 5--RUNNING TJ
   

TJ -- a Text Justifier		 				1-1

                              SECTION 1
                                    
                             INTRODUCTION
                                    
   
   
1-1.    TJ is a program designed to ease the burden of  documentation
for beleaguered computer  scientists.   It  provides  automatic  line
justification, centering, underlining, paragraph and spacing control.
Information may be printed in up to  4  adjacent  columns.   It  also
allows for special formatting and tabulation control.  TJ  gives  the
user control of column width, indentation, and page  size.   It  will
print page numbers in any of 12 formats and will  print  a  specified
title on each page if desired.
   
   
1-2.    Files to be printed by TJ are prepared using a  text  editor.
In addition to  the  text  itself,  special  control  characters  and
parameter-setting commands are interspersed.   These  characters  and
commands are introduced only when  special  functions  are  required.
For straightforward prose,  very  little  additional  information  is
required.
   
   

TJ -- a Text Justifier		 				2-1

                              SECTION 2
                                    
                           NORMAL OPERATION
                                    
   
   
2-1.    TJ treats the blank, carriage return, line feed,  form  feed,
and tab characters as delimiters.  All  other  characters,  with  the
exception of  special  control  characters  described  below  in  the
section on control characters are treated as "letters".  A word is  a
collection of these "letters" surrounded by one or more delimiters.
   
   
2-2.    TJ scans the input stream, placing the words it finds  in  an
array and counting the characters in each word.  When the sum of  the
number of characters in all the words  it  has  collected  (plus  the
minimum of one blank required between each pair of words) exceeds the
specified line length, all those words collected except the last  are
used to form an output line.
   
   
2-3.    The justification algorithm  virtually  guarantees  that  the
text will be aligned both on the left and right margin.  Extra spaces
are inserted between words in the line (from the left or  right  ends
in alternating lines) to insure that the line is  the  right  length.
Only if the number of blanks required is exceedingly large  will  the
algorithm give up and leave the line a bit shorter than usual.   This
seldom happens unless linelength is very short.
   
   
2-4.    The lines are saved in another core  array  until  enough  of
them are present to form an entire  column,  using  a  user-specified
column size.  When the number of columns specified by  the  user  has
been collected, the page is printed: first the title  and  perhaps  a
page number, then the text.  If the page number is to be  printed  at
the bottom of the page, it is then inserted.  A form  feed  character
is next inserted to eject the printer to the next page.
   
   
2-5.    Pages are saved in core to facilitate the multiple column and
"hold" features (see HOLD below).

TJ -- a Text Justifier		 				3-1

                              SECTION 3
                                    
                          CONTROL CHARACTERS
                                    
   
   
3-1.    The ever-vigilant  TJ  is  constantly  monitoring  the  input
stream for special (user-specified)  control  characters  which  will
cause it to take actions different from those described below.   Here
is a list of these control characters -- their mnemonic names,  their
initial values (λ means the feature is not enabled until an  explicit
command is given), and their functions:


MNEMONIC  INIT  FUNCTION


PERIOD    .     An extra space is normally added following a  period,
                if the period is followed in  the  input  file  by  a
                space, tab, carriage return, or form feed.   This  is
                sometimes obscured by  the  justification  algorithm,
                but at least there are never fewer  than  two  spaces
                following a period when it is used  for  punctuation.
                This function does not occur if  the  period  appears
                between WDELIM characters (see WDELIM  below).   This
                character is not subject to change by the user.


PDELIM    '11   A PDELIM character indicates that a new paragraph  is
                desired.  A carriage return is inserted at the end of
                the current line, which is  inserted  in  the  output
                list without justification.  The first line  of  each
                paragraph  is  displaced  by  the  current  value  of
                TABCONTROL (see below).  An extra blank line  or  two
                might be inserted  before  the  first  line  of  each
                paragraph, depending on  the  setting  of  PARASPACE.
                Tabcontrol may be positive or negative.


CRDELIM   λ     The current line is  terminated  immediately  when  a
                CRDELIM character is encountered.   Justification  is
                normally not done for this  line  (since  it  is  not
                necessary).  More than one  CRDELIM  character  cause
                extra blank lines to be inserted.


WDELIM    λ     It is sometimes desired to include control characters
                in the output  text,  or  to  keep  a  set  of  words
                together on a single  line  (e.g.,  the  abbreviation

TJ -- a Text Justifier		 				3-2

                "e.g.", or the words "IBM 360").  This may be done by
                surrounding the characters by WDELIM characters.   No
                other delimeters besides the  WDELIM  character  will
                affect  the  scan   within   these   brackets.    The
                characters  are  treated  as  a  single  word.    For
                example, in the above example, one would type  !e.g.!
                to keep the periods from expanding into extra spaces.
                A certain amount of care is required here  to  insure
                that these pseudo-words do not get  too  long,  since
                the algorithm can get a bit confused when  it  cannot
                find reasonable breaking points in  the  line  it  is
                creating.


QDELIM    λ     There are certain kinds of text (tables,  programming
                examples,  etc.)  which  would  suffer  rather   than
                benefit from the justification procedures of TJ.  For
                these occurrences, the QDELIM character is  provided.
                When such a character  is  encountered,  the  current
                line is terminated.   Then  all  lines  between  this
                character and the next QDELIM  character  are  passed
                directly  to  the   output   list.    No   horizontal
                justification is performed.  However,  TJ  does  keep
                track of the number of lines being output,  and  will
                cause a column break to occur if the specified number
                of lines is reached.  In addition, the appearance  of
                a form feed character between QDELIM characters  will
                cause an early page termination.  This  is  good  for
                ending sections, etc.  No other control character  is
                recognized between these characters.  No extra  blank
                lines are inserted when operating in this mode.


TDELIM    λ     For printing tables, a  feature  is  available  which
                allows the user  to  set  "tab-stops"  at  convenient
                points in the line  (see  COLUMNSET).   If  a  TDELIM
                character is  encountered  while  preparing  a  line,
                enough spaces are added to the last word to start the
                next word at the next  available  tab-stop  location.
                Justification is done only on the part  of  the  line
                following  the  last  TDELIM  character.   A  CRDELIM
                character should terminate every  tabbed  line  in  a
                table.  A message will be typed if a TDELIM character
                appears where there are no available tab-stops left.


KDELIM    λ     (Quote character) If a character directly  follows  a
                KDELIM character, this character is  passed  directly
                to the text-collector.  It will never function  as  a

TJ -- a Text Justifier		 				3-3

                control character.  Even the KDELIM character may  be
                quoted in this fashion.  For instance, if the  KDELIM
                character is π, and you want to print as part of your
                document the value of π, you can write:
                   
                     ππ = 3.14159.
                   
                Or  if  you  wish  to  describe  a  totally   winning
                operation,  you  can  type  that  it   was   100   π%
                successful, even if the command character is still %.
                When this manual  was  prepared,  KDELIM  was  ∃  and
                CDELIM π.  You can imagine what the source  for  this
                paragraph must have looked like.


CDELIM    %     The CDELIM  character  denotes  the  beginning  of  a
                command (parameter changing command).  Commands  have
                the following format (if you will permit me  to  drop
                out  of  this  beautifully  formatted  expose  for  a
                moment):
   

<command>                ::= CDELIM <command_list> GO 

<command_list>           ::= <command_item>
                         ::= <command_list> <command_item> 

<command_item>           ::= <verb> <argument> 

<argument>               ::= <character>
                         ::= <decimal_number>
                         ::= <delim> <character_string> <delim> 

<delim>                  ::= <same_arbitrary_character_both_times> 

<character_string>       ::= <string_of_not_delim_characters> 
   

TJ -- a Text Justifier		 				3-4

   
   
3-2.    
              A command causes the line to be terminated.   Then  the
              actions described in the next section are performed for
              each verb-argument pair.  Some of the  symbols  in  the
              above  carefully-contrived  syntax  will  be  left   as
              intuitive logical notions.  A list of the  legal  verbs
              will be found in the next section.   Any  verb  may  be
              shortened to the smallest number of characters required
              to recognize it uniquely.  All verbs and arguments must
              be separated by spaces.  A verb may be  entirely  upper
              or entirely lower case characters, but not a mixture.
   

TJ -- a Text Justifier		 				4-1

                              SECTION 4
                                    
                               COMMANDS
                                    
   
   
4-1.    Here is a  list  of  the  current  TJ  verbs,  their  initial
arguments, and the actions that are taken when they are  encountered.
λ  will  be  used  to  denote  character  arguments  which  are   not
initialized.   α  denotes  uninitialized  numerical  arguments.   STR
stands for any character string of the type described in 3-1.


VERB         TYPE  FUNCTION


LINELENGTH   69    Sets the maximum right margin for a  line  to  NUM
                   (the argument).  The total length of a print  line
                   is (LINELENGTH+COLSEP)*COLUMNS-COLSEP.


INDENT       0     Sets left  (column)  margin  to  NUM.   The  right
                   margin is  not  shifted  right  --  LINELENGTH  is
                   unaffected by the position of the left margin.


RINDENT      0     Sets the right margin to LINELENGTH -  NUM.   This
                   allows one to set the maximum  right  margin  once
                   and  to  decrease  it  by  relative  amounts   for
                   indented text.


SPACES       1     Sets the number of  blank  lines  to  be  inserted
                   between lines when not in QDELIM mode.   SPACES  1
                   causes   single   spacing.    SPACES   2    causes
                   double-spacing, etc.


LINESPER     49     Sets  the  maximum  number  of  text  lines  (not
                   including title and page number lines --  allow  2
                   each) to be printed on a given page to NUM.


COLUMNS      1     Sets the number of columns per page to NUM (up  to
                   4).  Do not switch the number  of  columns  except
                   after forcing a page ejection.


COLSEP       5     Each column will be horizontally spaced  from  the

TJ -- a Text Justifier		 				4-2

                   next by NUM characters.


PAGELOC      1     Allows specification of  the  position  (and  very
                   existence) of page numbers.   NUM=0  for  no  page
                   numbering, 1,2, or 3 for left,  center,  or  right
                   positioning of the page number at the top  of  the
                   page; 4,5, or 6 for corresponding positions across
                   the bottom of the page.


PAGEPREFIX   α     The current page  number  is  reset  to  0.   Page
                   numbers subsequently print as NUM-increment.


CENTER       0     If NUM≠0, subsequent lines will be centered on the
                   column   (horizontally).    Include   a    CRDELIM
                   character after each line to be  centered  or  you
                   will obtain the trivial case.  If NUM=0, centering
                   will no longer occur.


UNDERLINE    0     All subsequent (column) lines will  be  underlined
                   if NUM≠0.  NUM=0 turns off this dubious feature.


TABCONTROL   4     This parameter controls the offset for  the  first
                   line of each paragraph.  A positive number  causes
                   the line to  be  indented  NUM  extra  spaces.   A
                   negative number causes the line to be extended  to
                   the left by NUM spaces.  This  feature  is  handy,
                   when  used  in  conjunction  with  COLUMNSET   and
                   INDENT, for preparing tables like this one.


COLUMNSET    α     This command clears all  tab-stops  and  sets  the
                   first one at NUM.  When the line is tabbed to this
                   point, the next printing character will appear  in
                   column NUM.


,            α     The next tab-stop is set at NUM.  Although it need
                   not appear right  after  a  COLUMNSET  verb,  this
                   construct makes most sense.  That  is,  a  typical
                   COLUMNSET command is COLUMNSET 5 , 10 , 15 ...


PARASPACES   0     NUM is the number of blank lines  to  be  inserted
                   between paragraphs.

TJ -- a Text Justifier		 				4-3



HOLD         0     It  is  sometimes  desirable  to  keep  an  entire
                   section of text on one page or column.   This  can
                   be   done   by    forcing    a    page-eject    or
                   column-termination sequence early if failure to do
                   so would result in the section being broken over a
                   page boundary.  If NUM≠0 following  a  HOLD  verb,
                   all lines between the next one issued and the line
                   preceeding  the  next  HOLD  command  (of   either
                   flavor) will appear on the same column if  at  all
                   possible.  If NUM=0, the HOLD  feature  is  turned
                   off.


CDELIM       %     Sets the CDELIM character to the CHAR given


CRDELIM      λ     Sets the CRDELIM character to CHAR


TDELIM       λ     etc.


QDELIM       λ     etc.


WDELIM       λ     etc.


PDELIM       '11   etc.


KDELIM       λ     etc.


TITLE        STR   Sets the title line to be printed at  the  top  of
                   each  page  to  the  character  string   contained
                   between the delim characters.  The page number, if
                   it is present on the top of the  page,  is  always
                   pushed to the right by the title line (a crock).
   

TJ -- a Text Justifier		 				5-1

                              SECTION 5
                                    
                              RUNNING TJ
                                    
   
   
5-1.    Prepare a text file to be printed.  Follow  the  above  rules
carefully.  Call your file <file>.TJ or just <file>.
   
   
5-2.    Type the command:
   
COMPILE <file> /NONSTANDARD TJ[1,3]
   
    to the time-sharing system.
   
   
5-3.    List <file>.LST using the COPY command.
   
   
5-4.    Iterate.

TJ -- a Text Justifier		 				5-2

INDEX

 3- 1	<argument>
 3- 1	<character_string>
 3- 1	<command>
 3- 1	<command_item>
 3- 1	<command_list>
 4	COMMANDS
 3- 1	CONTROL CHARACTERS
 3- 1	<delim>
 3- 1	INTRODUCTION
 3- 1	NORMAL OPERATION
 5	RUNNING TJ